<?php

    if ( $article )
    {
        $admin_link = '';
        if ( $is_logged_in )
        {
            $admin_link = link_to('Edit',
                                  array('controller'=>'admin/news' ,'action'=>'modify?from_edit=1&id='.$article['id']));
        }
        // split content by more if its there.
        if ( strstr($article['content'],'<!--more-->') !== false)
        {
            $article['content'] = preg_replace('#<!--more-->#','<a name="read_more" id="read_more"></a>',$article['content'],1);                            
        }
        
        // news image
        $news_image = '';
        if ( !empty($article['file_id']) )
        {
            use_helper('admin/files');
            $path         = get_installed_path();
            $path_to_file = public_path_to_file($article['file_id']);
            // you can use w or h to change dimensions, plus all the other options for phpthumb
            $news_image   = "<img src='$path/img.php?src=$path/$path_to_file&h=100' class='news_image' />";
        }
        
        printf("<div class='news_story'>
                    <h3 class='news_story_title'>%s</h3>
                    %s
                    <div class='news_story_meta'>%s %s</div>
                    <div class='news_story_body'>%s</div> %s
                </div>",
                $article['title'],
                $news_image,
                date_format($article['publish_date']),
                $article['source'],
                $article['content'],
                $admin_link);
    } else {
        echo "<p>Sorry, but the request story could not be found.</p>";
    }
?>